package ui.units {

	import beans.IBean;
	
	import flash.display.Sprite;
	import flash.utils.getTimer;
	
	import globals.Global;
	import globals.Setting;
	
	public class BaseUnit extends Sprite implements IUnit {
		
		public var id:String;
		protected var view:UnitView;
		protected var now:uint;
		protected var past:uint;
		public var lifeTime:uint;
		public var direction:int;
		public var action:int;
		public var repeat:Boolean;
		protected var bean:UnitBean;

		public function BaseUnit() {
			super();
		}
		
		public function init(bean:UnitBean):void {
			this.bean = bean;
			past = 0;
			view = new UnitView(this);
			view.init(bean.url, bean.domain);
			addChild(view);
		}
		
		public function update():void {
			now = Global.timeStamp;
			var duration:int = now - past;
			if (duration > Setting.DURATION) {
				view.update(action, direction);
				past = now;
			}
		}
		
		public function clear():void {
		}
	}
}